package com.tip.calculator.service;

import com.tip.calculator.model.Tip;

public class TipService {
	
	private Tip tip;
	private float percentage;
	
	public TipService(Tip tip) {
		this.tip = tip;
	}

	public float getPercentageFromTipRating(float rating, float min, float max) {
		percentage = ((max - min) / 5) * rating + min;
		return percentage;
	}
	
	public float getTotalTip() {
		tip.setTotalTip((tip.getBillTotal() + tip.getTaxAmount()- tip.getBillDeduction()) * (percentage / 100));
		return tip.getTotalTip();
	}
	
	public float getPerPersonTip() {
		return tip.getTotalTip() / tip.getNumberOfGuests();
	}
	
	public float getTotalBillAndTip() {
		return tip.getBillTotal() + tip.getTotalTip() + tip.getTaxAmount() - tip.getBillDeduction();
	}	
	
}
